<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.*,java.io.*, java.sql.*, dbAccess.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Create New Patient</title>
<link rel="stylesheet" type="text/css" href="css_files/style.css" />
<script type="text/javascript">
function changeNumberofDays(code)
{
	var mylist;
	if (code == "1")
	{
		mylist = document.forms["frmSearchByRange"].cmbStartMonth;
	}
	else if (code == "2")
	{
		mylist = document.forms["frmSearchByRange"].cmbEndMonth;
	}
	else
	{
		mylist = document.forms["frmCreateAppt"].cmbMonth;
	}
	var month = mylist.selectedIndex;
	if ((month == 0) || (month == 2) || (month == 4) || (month == 6) || (month == 7) || (month == 9) || (month == 11))
	{
		var days;
		if (code == 1)
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else if (code == 2)
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		else
		{
			days = document.forms["frmCreateAppt"].cmbDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 31; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else if (month == 1)
	{
		var days;
		if (code == 1)
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else if (code == 2)
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		else
		{
			days = document.forms["frmCreateAppt"].cmbDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 28; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else
	{
		var days;
		if (code == 1)
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else if (code == 2)
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		else
		{
			days = document.forms["frmSearchByRange"].cmbDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 30; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
}

function IsValid() {
	var frm = document.forms["frmPatient"];
	//check each field for values, 3 at a time
	if ((frm.fName.value == "") || (frm.lName.value == "") || (frm.SIN.value == "")){
   		alert ("Please fill in all fields.");
      	return false;
    }
    if ((frm.EmailAddress.value == "") || (frm.phoneNumber.value == "") || (frm.HomeAddress.value == "")) {
    	alert ("Please fill in all fields.");
    	return false;
   	}
   	if ((frm.Password.value == "") || (frm.DateOfBirth.value == "") || (frm.healthCardNum.value == "")) {
    	alert ("Please fill in all fields.");
    	return false;
   	}
   	if  ((frm.Password.value != frm.confPassword.value)) {
   		alert ("Password inconsistency.");
   		return false;
   	}
   	return true;
}		


</script>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="150" height="125" valign="top"><img src="images/caduceus.gif" alt="" name="LogoLeft" width="150" height="125" id="LogoLeft" style="background-color: #0033FF" /></td>
    <td width="692" align="center" valign="middle"><h1 align="center">CADUCEUS HOSPITAL </h1></td>
    <td width="157" valign="top"><img src="images/hospital.jpg" alt="" name="LogoRight" width="150" height="125" id="LogoRight" style="background-color: #0033FF" /></td>
  </tr>
  <tr>
     <td height="19" colspan="2" valign="top">Welcome <%=session.getAttribute("Name")%>&nbsp;<%=new java.util.Date() %></td>
	<td align="right"> 
		<a href="home.jsp" title="Logout">Logout</a>
	</td> 
  </tr>
</table>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="259" valign="top"><p class="style2"></p>    
    
    	<table>
    		<tr>
    			    <td valign="top" class="style2"><p align="center"><strong>Quicklinks</strong></p>
    <p><a href="patientListforAdmin.jsp">View List of Patients</a></p>
    <p><a href="editAdmin.jsp">Change My Personal Information</a></p>
    <p><a href="http://www.webmd.com">WebMD</a></p>
	<p><a href="adminHome.jsp">Back to Homepage </a></p>
    <p>&nbsp;</p></td>
		</tr>
		</table>
    <td width="740" rowspan="0" class="style2", valign="top"><h3 align="left"><span class="style5"><strong>Enter New Patient Records</strong></span></h3>
    <form id="frmPatient" name="frmPatient" method="post" action="patientAddSaveForAdmin.jsp?action=add" onSubmit="return IsValid()">
    <table width="647">	
		<tr>
			<td width="117"><strong>
			  First Name					</strong></td>
		  <td width="518"><input name="firstName" type="text" id="firstName" /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Last Name
			</strong></td>
			<td><input name="lastName" type="text" id="lastName" /></td>
		</tr>
				
		<tr>
			<td><strong>
			  SIN
			</strong></td>
			<td><input name="SIN" type="text" id="SIN" /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Email Address
			</strong></td>
			<td><input name="emailAddress" type="text" id="emailAddress" /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Phone Number
			</strong></td>
			<td><input name="phone" type="text" id="phone" /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Home Address
			</strong></td>
			<td><input name="HomeAddress" type="text" id="HomeAddress" /></td>
		</tr>
		<tr>
		  <td><strong>Password</strong></td>
		  <td><input name="password" type="password" id="password" /></td>
	    </tr>
	    <tr>
		  <td><strong>Confirm Password</strong></td>
		  <td><input name="confPassword" type="password" id="confPassword" /></td>
	    </tr>
				
		<tr>
			<td><strong>
			  Date Of Birth (YYYY-MM-DD)
			</strong></td>
			<td><input name="DateOfBirth" type="text" id="DateOfBirth" /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Gender
			</strong></td>
			<td>
			  <input name="gender" type="radio" value="male" checked />
			  Male 
			  <input name="gender" type="radio" value="female" />
			  Female
			</td>
		</tr>
				
		<tr>
			<td>
			<strong> Health Card Number </strong>
			</td>
			<td><input type="healthCardNum" name="healthCardNum" />
			</td>
		</tr>
		<tr>
			<td>
			<strong> Doctor </strong>
			</td>
			<td>
				<select id="cmbDoctor" name="cmbDoctor">
					<%
						DbAccess access = new DbAccess();
						ResultSet rs;
						int docId;
						String docFirstName;
						String docLastName;
						String option;
						String query = "select tbl_doctor.DocId, tbl_doctor.FirstName, tbl_doctor.LastName ";
						query += "from tbl_doctor where tbl_doctor.IsDeleted = 0 ";
						query += "order by tbl_doctor.LastName";
						rs = access.ExecuteSelect(access.connect(), query);
					if (rs != null)
					{
						while (rs.next())
						{
							docLastName = rs.getString("tbl_doctor.LastName").trim();
							docFirstName = rs.getString("tbl_doctor.FirstName").trim();
							docId = rs.getInt("tbl_doctor.DocId");
							option = docLastName + "," + docFirstName + "-" + docId;
						%>
						<option><%=option%></option>
					<%	
						}
					}
					%>
				</select>
			</td>
		</tr>
		<tr>
			<td>
				 <input type="submit" name="cmdSave" id="cmdSave" value="Save"/>
			</td>
			<td>
				
			</td>
		</tr>
	</table>
    </form>	
    </td>
    
  
 
 
 </table>
</body>
</html>